<template>
  <div :class="className" :style="{height:height,width:width}" />
</template>

<script>
import * as echarts from 'echarts'
require('echarts/theme/macarons') // echarts theme
import resize from './mixins/resize'

export default {
  mixins: [resize],
  props: {
    className: {
      type: String,
      default: 'chart'
    },
    width: {
      type: String,
      default: '100%'
    },
    height: {
      type: String,
      default: '350px'
    }
  },
  data() {
    return {
      chart: null
    }
  },
  mounted() {
    this.$nextTick(() => {
      this.initChart()
    })
  },
  beforeDestroy() {
    if (!this.chart) {
      return
    }
    this.chart.dispose()
    this.chart = null
  },
  methods: {
    initChart() {
      this.chart = echarts.init(this.$el, 'macarons')
      var option = {
       
         title: {
    text: '教学评价'
  },
        xAxis: {
           axisTick:{
          show:false // 不显示坐标轴刻度线
    },
          type: 'category',
          data: ['老师1', '老师2', '老师3', '老师4', '老师5', '老师6', '老师7']
        },
        yAxis: {
          type: 'value',
           show:true, // 不显示坐标轴线、坐标轴刻度线和坐标轴上的文字
    axisTick:{
          show:false // 不显示坐标轴刻度线
    },
  

        },
        series: [{
          data: [80, 70, 60, 50, 40, 35, 30],
          type: 'bar',
          showBackground: true,
          // barWidth: '60%',
          itemStyle:{normal:{
            color:function(params){
              let colorList=[

                "#5a7fb7",
                 "#5a7fb7",
                  "#5a7fb7",
                   "#5a7fb7",
                    "#5a7fb7",
                     "#5a7fb7",
                      "#5a7fb7",
              ]
              return colorList[params.dataIndex];
            }
          }},
          backgroundStyle: {
            color: '#eeeeee'
          }
        }]
      }
      this.chart.setOption(option)
    }
  }
}
</script>
